/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package classcreatorgui;

import classcreator.ClassCreator;
import classcreator.DB.DBTables;
import classcreator.abstractclasses.AbstractClass;
import classcreator.abstractclasses.EnumDataType;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Samus
 */
public class Console {

    public static void main(String[] args) {
        Console cons = new Console();
        try {
            cons.starto();
        } catch (IOException ex) {
            Logger.getLogger(Console.class.getName()).log(Level.SEVERE, null, ex);
        }
//                cons.testMySQL();
//        cons.copyLibrary();
    }

    public void starto() throws IOException {
        ClassCreator.getInstance().setPackagename("Thereisnospoon");
        ClassCreator.getInstance().addAbsClass("A", "B", true);
        ClassCreator.getInstance().addAbsProp("A", "asdlfasdf", false, "String", "");
        ClassCreator.getInstance().addAbsProp("A", "aldwjfha", false, "Int", "");
//        ClassCreator.getInstance().addAbsFK("A", "asdlfasdf", "pkftw", "B", EnumDataType.INT);


        ClassCreator.getInstance().addAbsClass("B", "", false);
        ClassCreator.getInstance().addAbsProp("B", "pkftw", true, "Int", "");
        ClassCreator.getInstance().addAbsProp("B", "pkftw2", true, "Int", "");
        ClassCreator.getInstance().addAbsProp("B", "aldwjfha", false, "Int", "");
        ClassCreator.getInstance().addAbsProp("B", "propwhut", false, "Collection", "A");
        ClassCreator.getInstance().addAbsProp("B", "trial", false, "Collection", "Int");

//        CCMainGUI gui = new CCMainGUI();
//        gui.setVisible(true);

        ClassCreator.getInstance().assembleClasses();

        for (AbstractClass classsss : ClassCreator.getInstance().getClasesAbs()) {
            for (String st : classsss.getAssembledClass()) {
                System.out.println(st);
            }

            System.out.println(classsss.getSQLSentenceAdd());
            System.out.println(classsss.getSQLSentenceCreate());
            System.out.println(classsss.getSQLSentenceDelete());
            System.out.println(classsss.getSQLSentenceModify());
            System.out.println(classsss.getSQLSentenceFK());
        }
//        try {
//            ClassCreator.getInstance().executeAll();
//        } catch (SQLException ex) {
//            Logger.getLogger(Console.class.getName()).log(Level.SEVERE, null, ex);
//        }
    }

    public void testMySQL() {
        ClassCreator.getInstance().setPackagename("Thereisnospoon");
        try {
            DBTables.getInstance().createDatabase();
        } catch (SQLException ex) {
            Logger.getLogger(Console.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void copyLibrary() {
        ClassCreator.getInstance().setPackagename("Thereisnospoon");
        ClassCreator.getInstance().copyLibrary();
    }
}
